package com.leyou.common.adive;

import com.leyou.common.exceptions.ExceptionResult;
import com.leyou.common.exceptions.LyException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice //所有的Controller都会进入到这个类
public class BaseExceptionAdvice {

    @ExceptionHandler(LyException.class) //指定处理的异常类型
    public ResponseEntity<ExceptionResult> handlException(LyException e){
//        return ResponseEntity.ok(new ExceptionResult(e));
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ExceptionResult(e));
    }


}
